<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录页面</title>
</head>
<style>
    .bg{text-align: center;}
    .form-signin{max-width: 330px;margin: 100px auto}
    .form-signin-heading{margin-bottom: 30px;}
    .form-control{margin: 10px 0;}
    .tip{font-size: 12px;color: red}
</style>
<body>
    <div class="bg">
        <form class="form-signin" onsubmit="return false">
            <h2 class="form-signin-heading">星辰聊天系统请登录</h2>
            <label for="inputText" class="sr-only">用户名</label>
            <input type="text" id="inputText" class="form-control" placeholder="用户名" required="" autofocus="">
            <label for="inputPassword" class="sr-only">密码</label>
            <input type="password" id="inputPassword" class="form-control" placeholder="密码" required="">
            <textarea name="des" id="des" cols="44" rows="2" placeholder="请输入您的交友宣言..."></textarea>
            <button class="btn btn-lg btn-primary btn-block" id="logind">登录</button>
        </form>
        <lable class="tip">如果未注册会自动注册并登陆，已注册的用户会直接登录系统</lable>
    </div>
</body>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
<script src="https://cdn.bootcss.com/layer/2.3/layer.js"></script>
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script>
    $(function(){
        // 用户登录或者注册
        $("#logind").on('click',function(){
            var username = $("#inputText").val();
            var password = $("#inputPassword").val();
            var des = $("#des").val();
            if(username == '' || password == '') return layer.msg('请输入账号和密码');
            $.post('/index/Login/register',{'username':username,'password':password,'des':des},function(res){
                console.log(res);
                if(res.code == 200){
                    window.location.href = 'http://chat.ndstop.cn:9501/chat';
                } else {
                    layer.msg(res.msg);
                }
            })
        })
    })
</script>
</html>